package com.jack.helloworld.activity;

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.widget.SeekBar;
import android.widget.TextView;

import com.jack.helloworld.R;

public class SeekBarActivity extends AppCompatActivity implements SeekBar.OnSeekBarChangeListener {

    SeekBar seekBar;
    TextView tvSeekBarStatus;
    TextView tvSeekBarValue;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_seek_bar);

        initView();
        initData();
    }

    private void initView() {
        seekBar = (SeekBar) findViewById(R.id.seekBar);
        tvSeekBarStatus = (TextView) findViewById(R.id.tvSeekBarStatus);
        tvSeekBarValue = (TextView) findViewById(R.id.tvSeekBarValue);
    }

    private void initData() {
        seekBar.setOnSeekBarChangeListener(this);
    }

    @Override
    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        tvSeekBarStatus.setText(R.string.text_seekBar_moving);
        tvSeekBarValue.setText("values:" + progress);
    }

    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {
        tvSeekBarStatus.setText(R.string.text_seekBar_startMove);
    }

    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
        tvSeekBarStatus.setText(R.string.text_seekBar_stopMove);
    }
}
